-
Notifications
You must be signed in to change notification settings - Fork 446
FIX: Sending Queued Messages Lost When Clicking "Send Now" During Streaming #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary
Changes
Test plan
|
|
@1code review this pr |
|
Task completed. Now I have a good understanding of the changes. Let me provide my review. PR Review: #126 - Fix Queued Messages Lost When Clicking "Send Now" During StreamingOverviewThis PR addresses a significant bug where clicking "Send Now" on a queued message while the AI was streaming would cause the message to be lost entirely. The fix also addresses a related session ID race condition. Code Quality AssessmentOverall: Approve with minor suggestions Strengths
Issues & Suggestions1. Session context handling discrepancy (Medium priority)The PR description mentions two different behaviors:
Looking at the actual // The server-side save block sets sessionId=null on abort, so the next
// message starts fresh without needing an explicit cancel mutation.This comment contradicts the actual behavior. It should read similarly to line 3534. 2.
|
| Aspect | Rating |
|---|---|
| Bug fix correctness | ✅ Good |
| Code quality | ✅ Good |
| Error handling | ✅ Improved |
| Comments accuracy | |
| Test coverage | ⬜ Manual testing needed per test plan |
Verdict: Approve — The core bug fix is solid and the improvements to error handling are welcome. The stale comment at active-chat.tsx:3631 should be updated to match the actual behavior (sessionId is preserved, not nulled).
Powered by 1Code
|
merged |
## What's New ### Features - **Open Automations in Browser** — Automations now open in browser with external link icon ### Improvements & Fixes - **Send Now Fix** — Fixed queued messages being lost when clicking "Send Now" during streaming — thanks @jjjrmy! (#126) - **Symlinks in Skills** — Fixed symlink handling in skills - **Compact Commands** — Improved compact command display - **Plan Text Fix** — Fixed build plan text rendering
Summary
SESSION_EXPIREDerror) that occurred when aborting a stream and immediately starting a new message — the backend was resuming with an invalidated session ID saved by the cleanup handlerarePropsEqualinChatInputAreamissingqueueLength,firstQueueItemId, andonSendFromQueue, causing stale closures when queue state changedChanges
active-chat.tsxwaitForStreamingReady()helper that subscribes to Zustand store instead of polling withsetTimeout— includes a 30s safety timeout to prevent indefinite hangshandleSendFromQueuein try-catch; on failure, requeue the item viaprependItemso it is never losthandleForceSendsend call in try-catch; on failure, restore editor content viasetValueso the user can retrysetTimeoutpolling loops in bothhandleSendFromQueueandhandleForceSendwith the event-drivenwaitForStreamingReadyfetch('/api/agents/chat')DELETE calls fromhandleStopand keyboard handler (no REST server exists in Electron)ipc-chat-transport.tssessionInvalidatedflag set on abort to prevent the transport from reading a stalesessionIdfrom the last assistant message's metadataAgentMessageMetadatacast instead ofas anyfor metadata accesscancel.mutate()from abort handler — session cleanup is now handled server-sideclaude.tssessionIdfrom DB on abort (sessionId: abortController.signal.aborted ? null : metadata.sessionId) in both the error catch block and normal save blocksessionIdin the cleanup handler (unsubscribe callback) — only clearstreamIdsessionIdfrom DB when no active controller exists (handles the case where cleanup already removed fromactiveSessions)chat-input-area.tsxqueueLength,firstQueueItemId, andonSendFromQueuetoarePropsEqualto prevent stale closuresTest plan
SESSION_EXPIREDerror appears after the new message starts